<template name="imagePoup">
	<view class="imagePoupBox" v-if="isShow" @tap="close">
		<image  :src="initInfo.enter_banner?initInfo.enter_banner.url:''" mode="widthFix" @tap.stop="toPage" :data-url="initInfo.enter_banner.linkType==7?initInfo.enter_banner.linkUrl:initInfo.enter_banner.innerUrl"></image>
		<text class="iconfont icon-guanbi2" @tap="close"></text>
	</view>
</template>

<script>
	import {mapState,mapGetters,mapMutation,mapActions} from "vuex";
	export default{	
		name:'imagePoup',		//组件名称
		// 传递参数
		computed:{
			...mapState({
				initInfo:state=>state.sys.initInfo,
				isLogin: state => state.user.isLogin,
				userInfo:state=>state.user.userInfo
			})
		},
		props:{
			
		},
		// 组件参数
		data(){
			return {
				isShow: false
			}
		},
		// 组件方法
		methods:{
			close(){
				this.isShow=false;
			},
			show(){
				uni.setStorageSync("newCoupomTime",new Date().getTime())		//设定时间戳
				this.isShow=true;
			}
		},
		created() {
			setTimeout(()=>{
				let _now=new Date().getTime();
				let _isOverDay=false;
				if(uni.getStorageSync("newCoupomTime")){
					_isOverDay=(_now-uni.getStorageSync("newCoupomTime"))>(1000*60*60*24)
				}else{
					_isOverDay=true;
				}
				
				if(this.initInfo.enter_banner){		//已配置
					if(this.isLogin){		//已登录
						if(this.userInfo.registAward==0){		//未领取
							if(_isOverDay){	//超过1天
								this.show()
							}else{
								this.close()
							}
						}else{	//已领取
							this.close()
						}
					}else{		//未登录
						if(_isOverDay){	//超过1天
							this.show()
						}else{
							this.close()
						}
					}
				}else{		//未配置
					this.close()
				}
				
				
				
			},5000)
		}
	}
</script>

<style lang="less">
	.imagePoupBox{
		display: flex;
		flex-direction: column;
		background-color: rgba(0,0,0,0.5);
		position: fixed;
		width: 100%;
		height: 100%;
		top: 0;
		left: 0;
		z-index: 999999;
		justify-content: center;
		align-items: center;
		.iconfont{
			font-size: 60upx;
			color: #FFFFFF;
			margin-top: 40upx;
		}
		
		image{
			width: 76%;
		}
	}
</style>
